package jxc.web.tag;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

public class BaseURL extends TagSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1969411307256354146L;

	@Override
	public int doStartTag() throws JspException {
		HttpServletRequest request=(HttpServletRequest) this.pageContext.getRequest();
		String path = request.getContextPath();
		String basePath = request.getScheme() + "://"
				+ request.getServerName() + ":" + request.getServerPort()
				+ path + "/";
		try {
			pageContext.getOut().write(basePath);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return super.doStartTag();
	}

	
}
